/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JComponent;
import vical.model.Entry;

/**
 * The rectangle to display an entry, usually used for dayView and weekView
 * @author Can
 */
public class EntryCard extends JComponent {

    private Entry entry;
    private final int arcWidth = 18;
    private final int arcHeight = 18;
    private Color backColor = Color.LIGHT_GRAY;
    private Color borderColor = Color.GRAY;
    private Color textColor = Color.BLACK;
    private Font entryFont = new Font("SansSerif", Font.PLAIN, 10);
    private final int entrySpaceX = 10;
    private final int entrySpaceY = 13;

    public EntryCard(Entry entry) {
        this.entry = entry;
        if (this.entry != null) {
            this.setToolTipText(entry.getTaskDetailedString());
        }
    }

    @Override
    protected void paintComponent(Graphics g) {
        g.setColor(backColor);
        g.fillRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1, arcWidth, arcHeight);
        if (this.entry != null) {
            g.setFont(entryFont);
            g.setColor(textColor);
            g.drawString(entry.getName(), entrySpaceX, entrySpaceY);
        }
        super.paintComponent(g);
    }

    @Override
    protected void paintBorder(Graphics g) {
        g.setColor(borderColor);
        g.drawRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1, arcWidth, arcHeight);
        super.paintBorder(g);
    }
}
